<#assign module="driver"/>

<@override name="header">
</@override>
<@override name="body">
<div class="row">
	<div class="col-md-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				代驾员：${driver.realname?if_exists}（工号： ${driver.username}），评价记录
		    </div>
		</div>
	</div>
	
	<div class="col-xs-12">
  		<button class="pull-right btn btn-primary" onclick="window.location='${ctx}/rate/add/${driver.id}';"><i class="icon-plus"></i>&nbsp;添加评价</button>
  	</div>
</div>
	
<div class="row margin-top">
	<div class="col-xs-12">
	<div class="panel panel-primary">
	<div class="table-responsive">
		<table class="table table-hover table-striped">
			<thead>
			<tr style="font-size:14px;">
				<th>内容</th>
				<th>评分</th>
				<th>客户姓名</th>
				<th>订单号</th>
				<th>时间</th>
				<th>操作</th>
			</tr>
			</thead>
			<tbody>
				<#if (page.content)?? >
			  	<#list page.content as data>
					<tr>
						<td style="max-width:400px;">
							${data.content?if_exists}
						</td>
						<td>${data.starLevel?if_exists}星</td>
						<td>${data.memberName?if_exists}</td>
						<td>
							<#if data.orderNumber??>
							    <#if data.orderNumber?index_of("ZC")!=-1>
									<a target="_blank" href="${ctx}/zhuanche/detail/${data.orderId}">${data.orderNumber}</a>
								<#elseif data.orderNumber?index_of("PT")!=-1>
									<a target="_blank" href="${ctx}/errand/detail/${data.orderId}">${data.orderNumber}</a>
								<#elseif data.orderNumber?index_of("HY")!=-1>
								    <a target="_blank" href="${ctx}/freight/details/${data.orderId}">${data.orderNumber}</a>
								<#else>
									<a target="_blank" href="${ctx}/order/detail/${data.orderId}">${data.orderNumber}</a>
								</#if>
							</#if>
						</td>
						<td>${data.created?datetime}</td>
						<td>
							<a href="javascript:;" data-value="${data.id}" data-no="${data.orderNumber?if_exists}" class="btn-link deletethis">删除</a>
						</td>
					</tr>
				</#list>
				</#if>
			</tbody>
		</table>
		<#if page.totalElements??>
		<ul class="pagination pull-right pagination-sm">
			<li><a>共 ${page.totalElements} 条数据</a></li>
			<@pg.pager items=page.totalElements?number maxPageItems=20 export="currentPageNumber=pageNumber" url="${ctx}/rate/listByDriver/${driver.id}">
				<@pg.index>
					<@pg.first>
						<li><a href="${pageUrl}">&laquo;</a></li>
					</@pg.first>
					<@pg.prev>
						<li><a href="${pageUrl}">&lsaquo;</a></li>
					</@pg.prev>
					<@pg.pages>
						<#if  currentPageNumber == pageNumber >
							<li class="active"><a href="#">${pageNumber}</a></li>
						<#else>
							<li><a href="${pageUrl}">${pageNumber}</a></li>
						</#if>
					</@pg.pages>
					<@pg.next>
						<li><a href="${pageUrl}">&rsaquo;</a></li>
					</@pg.next>
					<@pg.last>
						<li><a href="${pageUrl}">&raquo;</a></li>
					</@pg.last>
				</@pg.index>
			</@pg.pager>
		</ul>
		</#if>
	</div>
	</div>
	</div>
</div>
</@override>

<@override name="footer">
	<script type="text/javascript">
		var thisButton;
		function deleteRate() {
		    $.post('${ctx}/rate/delete',{'id':thisButton.attr("data-value"),orderNo:thisButton.attr("data-no")},function(data){
		            if(data.success){
		            	thisButton.parent().parent().remove();
		                $.scojs_message('服务人员评价删除成功', $.scojs_message.TYPE_OK);
		            } else {
		                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
		            }
		    },'json');
		}
	
		$(document).ready(function(){
		    $(".deletethis").click(function(){
		          thisButton = $(this);
		          var confirm = $.scojs_confirm({
		            content: "确定要删除该服务人员评价吗？",
		            action:deleteRate
		          });
		          confirm.show();
		    });
		});
	</script>
</@override>
<@extends name="../layout.ftl"/>